import requests
from lxml import etree

url = 'https://qq.yh31.com/xq/wq/'
header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0'
}
res = requests.get(url=url, headers=header,verify=False)
res.encoding = res.apparent_encoding
data = res.text
tree = etree.HTML(data)
src_list = tree.xpath('//div[@class="sr"]//@data-src')
alt_list = tree.xpath('//div[@class="sr"]//@alt')
for src, alt in zip(src_list, alt_list):
    res = requests.get(url=src, headers=header)
    print(f'下载---{alt.strip()}---中')
    with open(f'./bqd/{alt}.png', 'wb') as f:
        f.write(res.content)
